from collections import defaultdict


def open_picuture(profile_path):
    try:
        return open(profile_path, "a+b")
    except OSError:
        print("打开文件失败")
        raise


pictures = defaultdict(open_picuture)

path = "profile_1234.png"

handle = pictures[path]
handle.seek(0)
image_data = handle.read()
